<?php 
class MenuManagerController extends SilkControllerBase {
	public function index( $params ) {
		//SilkResponse::create_url();
	}
	
	/**
	 * Build a menu automatically with the values passed in a hash
	 * in 'params'
	 *   - menuItems - a hash containing "text" => "URL"
	 *
	 * @param unknown_type $params
	 */
	public function auto_menu($params) {
		if( isset( $params["subMenu"] ) ) {
//			$suffix = "Sub";
			$suffix = "";
			$colour = "red";
		} else {
			$suffix = "";
			$colour = "blue";
		}
		$requestedPage = SilkRequest::get_requested_uri();
		if( substr( $requestedPage, strlen( $requestedPage ) -1, 1) == "?" ) {
			$requestedPage = substr( $requestedPage, 0, strlen( $requestedPage ) -1);
		}
		$menu = "<div class='menu bubplastic$suffix horizontal $colour'>";
		$menu .= "<ul>";
		foreach( $params["menuItems"] as $key => $value ) {
			if( $value == $requestedPage ) {
				$menu .= "<li class='highlight'><span class='menu_r'><a href='$value'><span class='menu_ar'>$key</span></a></span></li>";
			} else {
				$menu .= "<li><span class='menu_r'><a href='$value'><span class='menu_ar'>$key</span></a></span></li>";
			}
		}
		$menu .= "</ul>";
		$menu .= "<br class='clearit$suffix' />";
		$menu .= "</div>";
		if( isset($params["subMenu"])) {
			$this->set("auto_subMenu", $menu);
		} else {
			$this->set("auto_menu", $menu);
		}
		return $menu; //have to return it so we can assign it to another smarty var if we're using multiple menus on the same page
	}
} 